package com.twu.biblioteca.domain;

public class LibraryUser implements LibraryEntity {
    private final String userId;
    private final String password;
    private String firstName;
    private String lastName;
    private String emailAddress;
    private String phoneNumber;

    public LibraryUser(String userId, String password) {

        this.userId = userId;
        this.password = password;
    }

    @Override
    public String getId() {
        return userId;
    }

    @Override
    public int compareTo(Object o) {
        return 0;
    }

    @Override
    public boolean equals(Object o) {
        LibraryUser otherUser = (LibraryUser) o;
        return (otherUser.userId.equals(this.userId) &&


                otherUser.password.equals(this.password));
    }
    @Override
    public String toString(){
        return String.format("Name: %s %s. Email: %s. Phone: %s.", this.firstName, this.lastName, this.emailAddress, this.phoneNumber);
    }

    private LibraryUser(Builder builder) {
        this.userId = builder.userId;
        this.password = builder.password;
        this.firstName = builder.firstName;
        this.lastName = builder.lastName;
        this.emailAddress = builder.emailAddress;
        this.phoneNumber = builder.phoneNumber;
    }


    public static class Builder {
        private String firstName;
        private String lastName;
        private String emailAddress;
        private String phoneNumber;
        private final String userId;
        private final String password;

        public Builder(String userId, String password) {
            this.userId = userId;
            this.password = password;
        }


        public Builder setFirstName(String firstName) {
            this.firstName = firstName;
            return this;
        }

        public Builder setLastName(String lastName) {
            this.lastName = lastName;
            return this;
        }

        public Builder emailAddress(String email) {
            this.emailAddress = email;
            return this;
        }

        public Builder phoneNumber(String phoneNumber) {
            this.phoneNumber = phoneNumber;
            return this;
        }

        public LibraryUser build() {
            return new LibraryUser(this);
        }

    }
}
